package th.co.exat.uap.model;

import com.channgam.dbmlib.sql.MySQLJDBC;
import com.channgam.dbmlib.sql.iDataAdapter;
import th.co.exat.uap.config.Config;

public class EXATRate {
    private static iDataAdapter i;

    private String exitStationId;
    private String enterStationId;
    private String carTypeId;
    private String amount;

    public static String cheacRate(String enterStation, String exitStation, String carType) throws Exception {
        String rate = "";
        i = new MySQLJDBC(Config.getMySqlHost(),
                Config.getMySqlUsername(),
                Config.getMySqlPassword(),
                Config.getMySqlDbname());
        i.connect();
        String sql = "SELECT * "
                + "FROM uap_mst_charge c "
                + "WHERE enter_station_id = '" + enterStation + "' " +
                "AND exit_station_id = '" + exitStation + "' " +
                "AND cartype_id = '" + carType + "' ";
        i.query(sql);

        while (i.resultNext()) {
            rate = i.result().getString("amount");
        }

        i.close();
        return rate;
    }

    public String getAmount() {
        return amount;
    }

    public void setAmount(String amount) {
        this.amount = amount;
    }

    public String getCarTypeId() {
        return carTypeId;
    }

    public void setCarTypeId(String carTypeId) {
        this.carTypeId = carTypeId;
    }

    public String getEnterStationId() {
        return enterStationId;
    }

    public void setEnterStationId(String enterStationId) {
        this.enterStationId = enterStationId;
    }

    public String getExitStationId() {
        return exitStationId;
    }

    public void setExitStationId(String exitStationId) {
        this.exitStationId = exitStationId;
    }
    
}
